<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Employee List</title>
    </head>
    <body>
        <div class="undernav">
            <span class="menuButton"><g:link class="createEmployee" action="create">New Employee</g:link></span>
            <!-- This is the help button. -->
            <%  def help = Help.findByNameAndLanguage("employee_list", session.language)
            def helplink = createLink(action:'show', controller:'help', id: help.id )%>
            <a href="#" onClick="MyWindow=window.open('${helplink}','Help','width=350,height=450'); return false;">Help</a>
            <!-- This is the end of the help button. -->
        </div>
        <div class="body">
        <g:btnMode mode="${session.mode}"  currentController="employee" currentView="list"></g:btnMode>
            <h1>
             ${Inter.printOut('Employee List',session.language)}
            </h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                               <g:sortableColumn property="firstName" title="${Inter.printOut('Name',session.language)}" />

                                <g:sortableColumn property="title" title="${Inter.printOut('Title',session.language)}" />

                                <g:sortableColumn property="salary" title="${Inter.printOut('Monthly Salary',session.language)}" />

                                <g:sortableColumn property="percentageWork" title="${Inter.printOut('Working',session.language)}" />
                           </tr>
                    </thead>
                    <tbody>
                    <g:each in="${employeeInstanceList}" status="i" var="employeeInstance">
                    <!--add this to control switching in different modes-->
                    <g:if test="${ModeAccess.isAvailableInCurrentMode(session.mode,employeeInstance.mode)}">

                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">

                            <td><g:link action="show" id="${employeeInstance.id}">${fieldValue(bean:employeeInstance, field:'firstName')} ${fieldValue(bean:employeeInstance, field:'lastName')}</g:link></td>

                            <td><g:link action="show" id="${employeeInstance.id}">${fieldValue(bean:employeeInstance, field:'title')}</g:link></td>

                            <td>
                              <g:link action="show" id="${employeeInstance.id}"><g:formatNumber number="${employeeInstance.salary}" format="SEK ##,##0"/></g:link>
                            </td>

                            <td style="display:inline">
                                <g:link action="show" id="${employeeInstance.id}"><g:formatNumber number="${employeeInstance.percentageWork}" format="###.##"/> %
                                <g:if test="${employeeInstance.isWorkingOverTime()}"> <img style="display:inline" src="${resource(dir:'images',file:'spinner.gif')}"/></g:if></g:link>
                           
                              </td>
                        </tr>

                    </g:if>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${employeeInstanceTotal}" />
            </div>
        </div>
    </body>
</html>